/*
 *   Copyright (C) @2021 Webank Group Holding Limited
 *   <p>
 *   Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 *  in compliance with the License. You may obtain a copy of the License at
 *  <p>
 *  http://www.apache.org/licenses/LICENSE-2.0
 *   <p>
 *   Unless required by applicable law or agreed to in writing, software distributed under the License
 *   is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 *  or implied. See the License for the specific language governing permissions and limitations under
 *  he License.
 *
 */

package com.webank.openledger.demo.holder;


import com.webank.openledger.demo.entity.AssetEntity;

/**
 *
 */
public class AssetHolder {
    private static AssetEntity assetEntity;

    public static void setAsset(AssetEntity asset) {
        assetEntity = asset;
    }

    public static AssetEntity getAsset() throws Exception {
        if (assetEntity == null) {
            throw new Exception("asset not load,please run createAsset or run loadAsset");
        }
        return assetEntity;
    }

    public static void clear() {
        assetEntity = null;
    }

    public static Boolean isFungible() throws Exception {
        return getAsset().getIsFungible();
    }

}
